import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 马拉圈
 * Date: 2023-03-20
 * Time: 19:44
 */




class Counter {
    private int count = 0;
    public void add() {
        synchronized (Counter.class) {
            count++;
        }
    }
    public int get() {
        return count;
    }
}


public class Test1 {
    public static int count = 0;
    final static Object object = new Object();
    public static void main1(String[] args) throws InterruptedException {
        Counter counter = new Counter();
        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 50000; i++) {
                synchronized (object) {
                    count++;
                }
            }
        });
        for (int i = 0; i < 50000; i++) {
            synchronized (object) {
                count++;
            }
        }
        thread1.start();
        thread1.join();
        System.out.println(count);
    }
}
